<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>远程升级</title>
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
    <link href="../../resources/lib/bui/css/bs3/dpl-min.css"
          th:href="@{/resources/lib/bui/css/bs3/dpl-min.css}"
          rel="stylesheet" type="text/css" />
    <link href="../../resources/lib/bui/css/bs3/bui-min.css"
          th:href="@{/resources/lib/bui/css/bs3/bui-min.css}"
          rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../../resources/lib/bui/js/jquery-1.8.1.min.js"
            th:src="@{/resources/lib/bui/js/jquery-1.8.1.min.js}"></script>
    <script type="text/javascript" src="../../resources/lib/bui/js/bui-min.js"
            th:src="@{/resources/lib/bui/js/bui-min.js}"></script>
    <script th:inline="javascript" type="text/javascript">
        /*<![CDATA[*/
        /**
         * 应用程序URL根路径
         * @type {string}
         * @const
         */
        var BASE_URL = /*[[@{/}]]*/ '/';
        /*]]>*/
    </script>
</head>
<body>

<div class="page-header">
    <h1 class="h1">硬件程序远程升级</h1>
</div>
<div class="row" style="padding: 10px">

    <form  class="form-horizontal">

    <label class="control-label"><b>门控制器升级:</b></label>
    <div class="control-group">
        <div class="controls">
            软件版本号
            <input name="softVersion" type="number" class="input-small"
                   min="0" value="0"
                   data-rules="{required : true}">
        </div>
        <div class="controls">
            硬件版本号
            <input name="hardVersion" type="number" class="input-small"
                   min="0" value="0" data-rules="{required : true}"/>
        </div>
        <div class="controls">
            <div id="DcUploader"> </div>
        </div>
    </div>
    </form>

</div>
<div class="row" style="padding: 10px">
    <form  class="form-horizontal">
        <label class="control-label"><b>区域控制器升级:</b></label>
        <div class="control-group">
            <div class="controls">
                <div id="AcUploader"> </div>
            </div>
        </div>
    </form>
</div>

<script type="text/javascript">

//    var Tab = BUI.Tab
//    var Uploader = BUI.Uploader;
//
//    var tab = new Tab.TabPanel({
//        render : '#tab',
//        elCls : 'nav-tabs',
////        elCls : 'button-tabs',
//        panelContainer : '#panel',//如果内部有容器，那么会跟标签项一一对应，如果没有会自动生成
//        autoRender: true,
//        children:[
//            {title:'区域控制器升级',value:'1',selected : true},
//            {title:'门控制器升级',value:'2'}
//        ]
//    });
    BUI.use('bui/uploader',function (Uploader) {
        var dcUploader = new Uploader.Uploader({
            render: '#DcUploader',
            name:'file',
            text:'上传门控制器程序',
            url: '/update/uploadDC',
            isSuccess: function(result){
                console.log(result);
                if(result.ok){
                    BUI.Message.Alert('文件已上传成功，正在升级程序',function(){
                    },'info');
                } else {
                    BUI.Message.Alert('文件已上传出错:' + result.msg,function(){
                    },'info');
                }
                return result.ok;
            }
        }).render();
        dcUploader.on('start', function(e){
            dcUploader.set("data", {
                softVersion: $('input[name=softVersion]').val(),
                hardVersion: $('input[name=hardVersion]').val()
            });
        });

        var acUploader = new Uploader.Uploader({
            render: '#AcUploader',
            name:'file',
            text:'上传区域控制器程序',
            url: '/update/uploadAC',
            isSuccess: function(result){
                console.log(result);
                if(result.ok){
                    BUI.Message.Alert('文件已上传成功，正在升级程序',function(){
                    },'info');
                } else {
                    BUI.Message.Alert('文件已上传出错:' + result.msg,function(){
                    },'info');
                }
                return result.ok;
            },
            //失败的回调
            error: function(result){
                console.log(result);
            }
        }).render();
    });
    //tab.setSelected(tab.getItemAt(0));

</script>
</body>
</html>